<?php
/**
 * Created by PhpStorm.
 * User: zlkmu
 * Date: 2017/10/4
 * Time: 14:07
 * 服务器返回信息类
 */

    class ServerResponse{

        function processServerResponse($responseType,$userUid, $responseMsg){
            switch($responseType) {
                //如果是登录响应
                case ConnectAPI::$LOGIN_RESPONSE:
                    $this->loginResponse($userUid,$responseMsg);
                    break;

                //创建房间的响应
                case ConnectAPI::$CREATEROOM_RESPONSE:
                    $this->createRoomResponse($userUid,$responseMsg);
                    break;


            }
        }

        /**
         * 用于处理登录响应返回的函数
         * @param
         * @param
         */
        public function loginResponse($userUid,$responseMsg){
            echo "login OK\n";

            $msg["head_code"]=ConnectAPI::$LOGIN_RESPONSE;
            $msg["status"]=1;
            $msg["game_type"]=0;
            $msg["client_msg"]=json_decode(json_encode($responseMsg));

            \GatewayWorker\Lib\Gateway::sendToUid($userUid,$msg);

        }

        /**
         * 用于处理创建房间响应返回的函数
         * @param
         * @param
         */
        public function createRoomResponse($user_uid,$responseMsg){

            $msg["head_code"]=ConnectAPI::$CREATEROOM_RESPONSE;
            $msg["status"]=1;
            $msg["game_type"]=0;
            $msg["client_msg"]=$responseMsg;

            \GatewayWorker\Lib\Gateway::sendToUid($user_uid,$msg);
        }

        /**
         * 用于处理创建房间响应返回的函数
         * @param
         * @param
         */
        public function startGameResponse($user_uid,$response){

            \GatewayWorker\Lib\Gateway::sendToUid($user_uid,$response);
        }
    }





?>